import { useI18n } from '/@/hooks/web/useI18n';
import { BasicColumn, BasicTableProps, FormProps } from '/@/components/Table';
import {
  basInvOperPriceListData,
} from '/@/api/bas/mes/price/basInvOperPrice';

const { t } = useI18n('bas.mes.oper.basMesOper');

const modalProps = {
  title: t('计件价格选择'),
};

const searchForm: FormProps = {
  baseColProps: { lg: 6, md: 8 },
  labelWidth: 80,
  schemas: [
    {
      label: t('存货编码'),
      field: 'invCode',
      component: 'Input',
    },
    {
      label: t('工序编码'),
      field: 'operCode',
      component: 'Input',
    },
    {
      label: t('计件单价'),
      field: 'iprice',
      component: 'Input',
    },
    {
      label: t('生效日期'),
      field: 'enDate',
      component: 'DatePicker',
      componentProps: {
        format: 'YYYY-MM-DD HH:mm',
        showTime: { format: 'HH:mm' },
      },
    },
    {
      label: t('失效日期'),
      field: 'exDate',
      component: 'DatePicker',
      componentProps: {
        format: 'YYYY-MM-DD HH:mm',
        showTime: { format: 'HH:mm' },
      },
    },
    {
      label: t('创建时间'),
      field: 'createDate',
      component: 'DatePicker',
      componentProps: {
        format: 'YYYY-MM-DD HH:mm',
        showTime: { format: 'HH:mm' },
      },
    },
  ],
};

const tableColumns: BasicColumn[] = [
  {
    title: t('存货编码'),
    dataIndex: 'invCode',
    key: 'a.inv_code',
    sorter: true,
    width: 230,
    align: 'left',
    slot: 'firstColumn',
  },
  {
    title: t('工序编码'),
    dataIndex: 'operCode',
    key: 'a.oper_code',
    sorter: true,
    width: 130,
    align: 'left',
  },
  {
    title: t('计件单价'),
    dataIndex: 'iprice',
    key: 'a.iprice',
    sorter: true,
    width: 130,
    align: 'right',
  },
  {
    title: t('生效日期'),
    dataIndex: 'enDate',
    key: 'a.en_date',
    sorter: true,
    width: 130,
    align: 'center',
  },
  {
    title: t('失效日期'),
    dataIndex: 'exDate',
    key: 'a.ex_date',
    sorter: true,
    width: 130,
    align: 'center',
  },
  {
    title: t('创建时间'),
    dataIndex: 'createDate',
    key: 'a.create_date',
    sorter: true,
    width: 130,
    align: 'center',
  },
  {
    title: t('更新时间'),
    dataIndex: 'updateDate',
    key: 'a.update_date',
    sorter: true,
    width: 130,
    align: 'center',
  },
  {
    title: t('状态'),
    dataIndex: 'status',
    key: 'a.status',
    sorter: true,
    width: 130,
    align: 'center',
    dictType: 'sys_search_status',
  },
];

const tableProps: BasicTableProps = {
  api: basInvOperPriceListData,
  beforeFetch: (params) => {
    params['isAll'] = true;
    //params['ope'] = '1';
    params['status'] = '0';
    return params;
  },
  columns: tableColumns,
  formConfig: searchForm,
  rowKey: 'id',
};

export default {
  modalProps,
  tableProps,
  itemCode: 'invCode',
  itemName: 'operCode',
};
